﻿using System;

namespace winS.UnityEditor.UIElement
{
    /// <summary>
    /// 侧边栏按钮
    /// </summary>
    public class SidebarButton : Button
    {
        public new event Action<int> onClick;

        public int index { get; set; } = -1;

        public SidebarButton() : base(EditorElementUtility.elementFactory)
        {
            style.flexGrow = 1f;
            style.SetMargin(0f);
            style.SetBorderWidth(0f);
            style.SetBorderRadius(0f);
            base.onClick += () => onClick?.Invoke(index);
        }
        public SidebarButton(int index) : this()
        {
            this.index = index;
        }

        public void Activate()
        {
            onClick?.Invoke(index);
        }
    }
}
